<?php
/**
 * Class FormRegistration created by Pixoid.
 *
 * @version 1.0
 */
class FormSettings extends User {

    public $config = array();

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function init() {
        $this->config = array(
            'class' => 'form',
            'activeForm' => array(
                'class' => 'CActiveForm',
                'enableAjaxValidation' => true,
                'enableClientValidation' => true,
                'id' => 'profile-form'
            ),
            'elements' => array(
                'username' => array('type' => 'text'),
                'country' => array('type' => 'text'),
                'town' => array('type' => 'text'),
                'telephone' => array('type' => 'text'),
            ),
            'buttons' => array(
                'sand' => array(
                    'type' => 'htmlSubmit',  'value' => 1, 'class' => 'blue', 'label' => '<span class="label">Сохранить</span>'),
            )
        );
        return parent::init();
    }

    public function rules() {
        return array(
            array('telephone', 'match', 'pattern' => '/^[0-9_]+$/u'),
            array('email, username', 'required'),
            array('country, town, telephone', 'safe'),
        );
    }

    public function attributeLabels() {
        return array(
            'username' => 'Имя пользователя',
            'country' => 'Страна',
            'town' => 'Город',
            'telephone' => 'Телефон'
        );
    }

}
